package cn.getech.data.development.utils.cloudera;

public class CMApi {

    /***
     * 登录的api
     */
    public static final String LOGIN_API = "/j_spring_security_check";

    /***
     * 获取集群的hosts数据api
     */
    public static final String HOST_OWERVIEW_API = "/cmf/hardware/hosts/hostsOverview.json?clusterId=1";

    /***
     * 获取集群的CPU的sql
     */
    public static final String CPU_HISTORY_SQL = "select cpu_percent_across_hosts where category = CLUSTER";

    /***
     * 获取集群的CPU的sql
     */
    public static final String LAST_CPU_HISTORY_SQL = "select last(cpu_percent_across_hosts) where category = CLUSTER";

    /***
     * 获取集群的CPU的sql
     */
    public static final String LAST_HOST_CPU_HISTORY_SQL = "select last(cpu_user_rate / getHostFact(numCores, 1) * 100) where entityName=";

    /***
     * 获取集群的CPU的sql
     */
    public static final String LAST_HOST_IO_CPU_HISTORY_SQL = "select last(total_read_ios_rate_across_disks), last(total_write_ios_rate_across_disks) where entityName=";

    /***
     * 获取集群的io的sql
     */
    public static final String NET_IO_HISTORY_SQL = "select total_bytes_receive_rate_across_network_interfaces, total_bytes_transmit_rate_across_network_interfaces where category = CLUSTER";


    /***
     * 获取集群的hdfs的sql
     */
    public static final String HDFS_HISTORY_SQL = "select dfs_capacity, dfs_capacity_used, dfs_capacity_used_non_hdfs where entityName=hdfs:";

    /***
     * 获取集群的yarn的queue的sql
     */
    public static final String YARN_QUEUE_HISTORY_SQL = "SELECT allocated_memory_mb where category=YARN_POOL and serviceName=yarn";

    /***
     * 获取集群的yarn的queue的sql
     */
    public static final String YARN_QUEUE_LAST_SQL = "SELECT last(allocated_memory_mb) where category=YARN_POOL and serviceName=yarn";

    public static String pingHttpUrl(String address,Integer host){
        return "http://" + address + ":" + host;
    }
    public static String pingHttpsUrl(String address,Integer host){
        return "https://" + address + ":" + host;
    }
}
